
import UIKit
import SnapKit


class CompletionCell : UICollectionViewCell{
    var completion: Completion!
    func bindViewModel(_ completion: Completion) {
        avatarImageView.kf.setImage(with: URL(string: completion.cover))
        nameLabel.text = completion.title
        subLabel.text = completion.subTitle
    }
    
    
    
    var avatarImageView: UIImageView = {
        let cover = UIImageView()
        cover.layer.cornerRadius = 8
        cover.contentMode = UIView.ContentMode.scaleAspectFill
        cover.clipsToBounds = true
        cover.isUserInteractionEnabled = true
        return cover
    }()
    
    var nameLabel: UILabel = {
        let titelLabel = UILabel()
        titelLabel.font = UIFont.boldSystemFont(ofSize: 15)
        titelLabel.textColor = .white
        titelLabel.text = "学习顾问"
        titelLabel.numberOfLines = 1
        return titelLabel
    }()
    

    var subLabel: UILabel = {
        let titelLabel = UILabel()
        titelLabel.font = UIFont.systemFont(ofSize: 12)
        titelLabel.textColor = .white
        titelLabel.numberOfLines = 2
        return titelLabel
    }()
    
    
    
    
    
    @objc private func handleRightBarButtonTapped(_ sender: Any) {
        
    }
    
    @objc func chatTapped(tapGestureRecognizer: UITapGestureRecognizer)
    {
        //        delegate?.didTapChat(user: user)
    }
    override init(frame: CGRect) {
        super.init(frame: .zero)
        self.addSubview(avatarImageView)
        self.addSubview(nameLabel)
        self.addSubview(subLabel)
        
        
        self.backgroundColor = primaryBackgroundColor
        self.layer.cornerRadius = 12
        
       
        avatarImageView.snp.makeConstraints { make in
            make.centerY.equalTo(self)
            make.left.equalTo(self).offset(8)
            make.width.equalTo(30)
            make.height.equalTo(30)
            
        }
        
        
      
        
        
        nameLabel.snp.makeConstraints { make in
            make.bottom.equalTo(avatarImageView.snp.centerY).offset(-10)
            make.left.equalTo(avatarImageView.snp.right).offset(16)
            make.right.equalTo(self).offset(-12)
            
        }
        
        subLabel.snp.makeConstraints { make in
            make.top.equalTo(avatarImageView.snp.centerY).offset(3)
            make.left.equalTo(nameLabel)
            make.right.equalTo(nameLabel)
            
        }
        
        
      
        
       
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

